<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <script src="./lib/vue-2.4.0.js"></script>
    <style>
        li {
            border: 1px dashed #999;
            margin: 5px;
            line-height: 35px;
            padding-left: 5px;
            font-size: 12px;
            width: 100%;
        }

        li:hover {
            background-color: pink;
            transition: all 0.6s ease;
        }

        /* 动画部分 */
        .v-enter,
        .v-leave-to {
            opacity: 0;
            transform: translateY(80px);
        }

        .v-enter-active,
        .v-leave-active {
            transition: all 1s ease;
        }

        /* 下面的v-move和.v-leave-active配合使用能让列表后面元素渐渐上漂 */

        .v-move {
            transition: all 0.6s ease;
        }

        .v-leave-active {
            position: absolute;
        }
    </style>
</head>

<body>
    <div id="app">
        <div>
            <label>
                Id:
                <input type="text" v-model="id">
            </label>

            <label>
                Name:
                <input type="text" v-model="name">
            </label>

            <input type="button" value="添加" @click="add">
        </div>
        <transition-group appear tag="ul">
            <li v-for="(item,i) in list " :key='i' @click="del(i)">
                {{item.id}}-----{{item.name}}
            </li>
        </transition-group>

    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                list: [
                    { id: 1, name: '田余帅' },
                    { id: 2, name: '郑烽' },
                    { id: 3, name: '赵高' },
                    { id: 4, name: '魏忠贤' }
                ]
            },
            methods: {
                add(){
                    this.list.push({id:this.id,name:this.name})
                    this.id =this.name =''
                },
                del(i){
                    this.list.splice(i,1);
                }
            }
        })
    </script>
</body>

</html>